package com.edu.study.base.stuCourseExercisesResult.controller;

import java.util.List;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.edu.study.base.stuCourseExercisesResult.domain.StuCourseExercisesResult;
import com.edu.study.base.stuCourseExercisesResult.service.IStuCourseExercisesResultService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 课后练习结果汇总Controller
 * 
 * @author zw
 * @date 2021-08-30
 */
@RestController
@RequestMapping("/stuCourseExercisesResult/stuCourseExercisesResult")
public class StuCourseExercisesResultController extends BaseController
{
    @Autowired
    private IStuCourseExercisesResultService stuCourseExercisesResultService;

    /**
     * 查询课后练习结果汇总列表
     */
    @PreAuthorize("@ss.hasPermi('stuCourseExercisesResult:stuCourseExercisesResult:list')")
    @GetMapping("/list")
    public TableDataInfo list(StuCourseExercisesResult stuCourseExercisesResult)
    {
        startPage();
        List<StuCourseExercisesResult> list = stuCourseExercisesResultService.selectStuCourseExercisesResultList(stuCourseExercisesResult);
        return getDataTable(list);
    }

    @GetMapping("/getTeacherTaskList")
    public TableDataInfo getTeacherTaskList(StuCourseExercisesResult stuCourseExercisesResult)
    {
        startPage();
        List<StuCourseExercisesResult> list = stuCourseExercisesResultService.selectTeacherTaskList(stuCourseExercisesResult);
        return getDataTable(list);
    }

    /**
     * 导出课后练习结果汇总列表
     */
    @PreAuthorize("@ss.hasPermi('stuCourseExercisesResult:stuCourseExercisesResult:export')")
    @Log(title = "课后练习结果汇总", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(StuCourseExercisesResult stuCourseExercisesResult)
    {
        List<StuCourseExercisesResult> list = stuCourseExercisesResultService.selectStuCourseExercisesResultList(stuCourseExercisesResult);
        ExcelUtil<StuCourseExercisesResult> util = new ExcelUtil<StuCourseExercisesResult>(StuCourseExercisesResult.class);
        return util.exportExcel(list, "stuCourseExercisesResult");
    }

    /**
     * 获取课后练习结果汇总详细信息
     */
    @PreAuthorize("@ss.hasPermi('stuCourseExercisesResult:stuCourseExercisesResult:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(stuCourseExercisesResultService.selectStuCourseExercisesResultById(id));
    }

    /**
     * 新增课后练习结果汇总
     */
    @PreAuthorize("@ss.hasPermi('stuCourseExercisesResult:stuCourseExercisesResult:add')")
    @Log(title = "课后练习结果汇总", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody StuCourseExercisesResult stuCourseExercisesResult)
    {
        return toAjax(stuCourseExercisesResultService.insertStuCourseExercisesResult(stuCourseExercisesResult));
    }

    /**
     * 修改课后练习结果汇总
     */
    @PreAuthorize("@ss.hasPermi('stuCourseExercisesResult:stuCourseExercisesResult:edit')")
    @Log(title = "课后练习结果汇总", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody StuCourseExercisesResult stuCourseExercisesResult)
    {
        return toAjax(stuCourseExercisesResultService.updateStuCourseExercisesResult(stuCourseExercisesResult));
    }

    /**
     * 删除课后练习结果汇总
     */
    @PreAuthorize("@ss.hasPermi('stuCourseExercisesResult:stuCourseExercisesResult:remove')")
    @Log(title = "课后练习结果汇总", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(stuCourseExercisesResultService.deleteStuCourseExercisesResultByIds(ids));
    }
}
